home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / gnugrep / part05 < prev    next >
Encoding:
Internet Message Format  |  1989-02-08  |  13.5 KB

  1. Subject:  v17i102:  Gnu E?GREP (it's fast), Part05/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Mike Haertel <mike@wheaties.ai.mit.edu>
  7. Posting-number: Volume 17, Issue 102
  8. Archive-name: gnugrep/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of shell archive."
  17. # Contents:  regex.h
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'regex.h' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'regex.h'\"
  21. else
  22. echo shar: Extracting \"'regex.h'\" \(12504 characters\)
  23. sed "s/^X//" >'regex.h' <<'END_OF_FILE'
  24. X/* Definitions for data structures callers pass the regex library.
  25. X   Copyright (C) 1985 Free Software Foundation, Inc.
  26. X
  27. X               NO WARRANTY
  28. X
  29. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  30. XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  31. XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  32. XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  33. XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  34. XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  35. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  36. XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  37. XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  38. XCORRECTION.
  39. X
  40. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  41. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  42. XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  43. XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  44. XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  45. XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  46. XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  47. XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  48. XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  49. XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  50. X
  51. X        GENERAL PUBLIC LICENSE TO COPY
  52. X
  53. X  1. You may copy and distribute verbatim copies of this source file
  54. Xas you receive it, in any medium, provided that you conspicuously and
  55. Xappropriately publish on each copy a valid copyright notice "Copyright
  56. X(C) 1985 Free Software Foundation, Inc."; and include following the
  57. Xcopyright notice a verbatim copy of the above disclaimer of warranty
  58. Xand of this License.  You may charge a distribution fee for the
  59. Xphysical act of transferring a copy.
  60. X
  61. X  2. You may modify your copy or copies of this source file or
  62. Xany portion of it, and copy and distribute such modifications under
  63. Xthe terms of Paragraph 1 above, provided that you also do the following:
  64. X
  65. X    a) cause the modified files to carry prominent notices stating
  66. X    that you changed the files and the date of any change; and
  67. X
  68. X    b) cause the whole of any work that you distribute or publish,
  69. X    that in whole or in part contains or is a derivative of this
  70. X    program or any part thereof, to be licensed at no charge to all
  71. X    third parties on terms identical to those contained in this
  72. X    License Agreement (except that you may choose to grant more extensive
  73. X    warranty protection to some or all third parties, at your option).
  74. X
  75. X    c) You may charge a distribution fee for the physical act of
  76. X    transferring a copy, and you may at your option offer warranty
  77. X    protection in exchange for a fee.
  78. X
  79. XMere aggregation of another unrelated program with this program (or its
  80. Xderivative) on a volume of a storage or distribution medium does not bring
  81. Xthe other program under the scope of these terms.
  82. X
  83. X  3. You may copy and distribute this program (or a portion or derivative
  84. Xof it, under Paragraph 2) in object code or executable form under the terms
  85. Xof Paragraphs 1 and 2 above provided that you also do one of the following:
  86. X
  87. X    a) accompany it with the complete corresponding machine-readable
  88. X    source code, which must be distributed under the terms of
  89. X    Paragraphs 1 and 2 above; or,
  90. X
  91. X    b) accompany it with a written offer, valid for at least three
  92. X    years, to give any third party free (except for a nominal
  93. X    shipping charge) a complete machine-readable copy of the
  94. X    corresponding source code, to be distributed under the terms of
  95. X    Paragraphs 1 and 2 above; or,
  96. X
  97. X    c) accompany it with the information you received as to where the
  98. X    corresponding source code may be obtained.  (This alternative is
  99. X    allowed only for noncommercial distribution and only if you
  100. X    received the program in object code or executable form alone.)
  101. X
  102. XFor an executable file, complete source code means all the source code for
  103. Xall modules it contains; but, as a special exception, it need not include
  104. Xsource code for modules which are standard libraries that accompany the
  105. Xoperating system on which the executable file runs.
  106. X
  107. X  4. You may not copy, sublicense, distribute or transfer this program
  108. Xexcept as expressly provided under this License Agreement.  Any attempt
  109. Xotherwise to copy, sublicense, distribute or transfer this program is void and
  110. Xyour rights to use the program under this License agreement shall be
  111. Xautomatically terminated.  However, parties who have received computer
  112. Xsoftware programs from you with this License Agreement will not have
  113. Xtheir licenses terminated so long as such parties remain in full compliance.
  114. X
  115. X  5. If you wish to incorporate parts of this program into other free
  116. Xprograms whose distribution conditions are different, write to the Free
  117. XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  118. Xworked out a simple rule that can be stated here, but we will often permit
  119. Xthis.  We will be guided by the two goals of preserving the free status of
  120. Xall derivatives of our free software and of promoting the sharing and reuse of
  121. Xsoftware.
  122. X
  123. X
  124. XIn other words, you are welcome to use, share and improve this program.
  125. XYou are forbidden to forbid anyone else to use, share and improve
  126. Xwhat you give them.   Help stamp out software-hoarding!  */
  127. X
  128. X
  129. X/* Define number of parens for which we record the beginnings and ends.
  130. X   This affects how much space the `struct re_registers' type takes up.  */
  131. X#ifndef RE_NREGS
  132. X#define RE_NREGS 10
  133. X#endif
  134. X
  135. X/* These bits are used in the obscure_syntax variable to choose among
  136. X   alternative regexp syntaxes.  */
  137. X
  138. X/* 1 means plain parentheses serve as grouping, and backslash
  139. X     parentheses are needed for literal searching.
  140. X   0 means backslash-parentheses are grouping, and plain parentheses
  141. X     are for literal searching.  */
  142. X#define RE_NO_BK_PARENS 1
  143. X
  144. X/* 1 means plain | serves as the "or"-operator, and \| is a literal.
  145. X   0 means \| serves as the "or"-operator, and | is a literal.  */
  146. X#define RE_NO_BK_VBAR 2
  147. X
  148. X/* 0 means plain + or ? serves as an operator, and \+, \? are literals.
  149. X   1 means \+, \? are operators and plain +, ? are literals.  */
  150. X#define RE_BK_PLUS_QM 4
  151. X
  152. X/* 1 means | binds tighter than ^ or $.
  153. X   0 means the contrary.  */
  154. X#define RE_TIGHT_VBAR 8
  155. X
  156. X/* 1 means treat \n as an _OR operator
  157. X   0 means treat it as a normal character */
  158. X#define RE_NEWLINE_OR 16
  159. X
  160. X/* 0 means that a special characters (such as *, ^, and $) always have
  161. X     their special meaning regardless of the surrounding context.
  162. X   1 means that special characters may act as normal characters in some
  163. X     contexts.  Specifically, this applies to:
  164. X    ^ - only special at the beginning, or after ( or |
  165. X    $ - only special at the end, or before ) or |
  166. X    *, +, ? - only special when not after the beginning, (, or | */
  167. X#define RE_CONTEXT_INDEP_OPS 32
  168. X
  169. X/* Now define combinations of bits for the standard possibilities.  */
  170. X#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
  171. X#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
  172. X#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  173. X#define RE_SYNTAX_EMACS 0
  174. X
  175. X/* This data structure is used to represent a compiled pattern. */
  176. X
  177. Xstruct re_pattern_buffer
  178. X  {
  179. X    char *buffer;    /* Space holding the compiled pattern commands. */
  180. X    int allocated;    /* Size of space that  buffer  points to */
  181. X    int used;        /* Length of portion of buffer actually occupied */
  182. X    char *fastmap;    /* Pointer to fastmap, if any, or zero if none. */
  183. X            /* re_search uses the fastmap, if there is one,
  184. X               to skip quickly over totally implausible characters */
  185. X    char *translate;    /* Translate table to apply to all characters before comparing.
  186. X               Or zero for no translation.
  187. X               The translation is applied to a pattern when it is compiled
  188. X               and to data when it is matched. */
  189. X    char fastmap_accurate;
  190. X            /* Set to zero when a new pattern is stored,
  191. X               set to one when the fastmap is updated from it. */
  192. X    char can_be_null;   /* Set to one by compiling fastmap
  193. X               if this pattern might match the null string.
  194. X               It does not necessarily match the null string
  195. X               in that case, but if this is zero, it cannot.
  196. X               2 as value means can match null string
  197. X               but at end of range or before a character
  198. X               listed in the fastmap.  */
  199. X  };
  200. X
  201. X/* Structure to store "register" contents data in.
  202. X
  203. X   Pass the address of such a structure as an argument to re_match, etc.,
  204. X   if you want this information back.
  205. X
  206. X   start[i] and end[i] record the string matched by \( ... \) grouping i,
  207. X   for i from 1 to RE_NREGS - 1.
  208. X   start[0] and end[0] record the entire string matched. */
  209. X
  210. Xstruct re_registers
  211. X  {
  212. X    int start[RE_NREGS];
  213. X    int end[RE_NREGS];
  214. X  };
  215. X
  216. X/* These are the command codes that appear in compiled regular expressions, one per byte.
  217. X  Some command codes are followed by argument bytes.
  218. X  A command code can specify any interpretation whatever for its arguments.
  219. X  Zero-bytes may appear in the compiled regular expression. */
  220. X
  221. Xenum regexpcode
  222. X  {
  223. X    unused,
  224. X    exactn,    /* followed by one byte giving n, and then by n literal bytes */
  225. X    begline,   /* fails unless at beginning of line */
  226. X    endline,   /* fails unless at end of line */
  227. X    jump,     /* followed by two bytes giving relative address to jump to */
  228. X    on_failure_jump,     /* followed by two bytes giving relative address of place
  229. X                    to resume at in case of failure. */
  230. X    finalize_jump,     /* Throw away latest failure point and then jump to address. */
  231. X    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
  232. X                This is used to jump back to the beginning
  233. X                of a repeat.  If the command that follows
  234. X                this jump is clearly incompatible with the
  235. X                one at the beginning of the repeat, such that
  236. X                we can be sure that there is no use backtracking
  237. X                out of repetitions already completed,
  238. X                then we finalize. */
  239. X    dummy_failure_jump,  /* jump, and push a dummy failure point.
  240. X                This failure point will be thrown away
  241. X                if an attempt is made to use it for a failure.
  242. X                A + construct makes this before the first repeat.  */
  243. X    anychar,     /* matches any one character */
  244. X    charset,     /* matches any one char belonging to specified set.
  245. X            First following byte is # bitmap bytes.
  246. X            Then come bytes for a bit-map saying which chars are in.
  247. X            Bits in each byte are ordered low-bit-first.
  248. X            A character is in the set if its bit is 1.
  249. X            A character too large to have a bit in the map
  250. X            is automatically not in the set */
  251. X    charset_not, /* similar but match any character that is NOT one of those specified */
  252. X    start_memory, /* starts remembering the text that is matched
  253. X            and stores it in a memory register.
  254. X            followed by one byte containing the register number.
  255. X            Register numbers must be in the range 0 through NREGS. */
  256. X    stop_memory, /* stops remembering the text that is matched
  257. X            and stores it in a memory register.
  258. X            followed by one byte containing the register number.
  259. X            Register numbers must be in the range 0 through NREGS. */
  260. X    duplicate,    /* match a duplicate of something remembered.
  261. X            Followed by one byte containing the index of the memory register. */
  262. X    before_dot,     /* Succeeds if before dot */
  263. X    at_dot,     /* Succeeds if at dot */
  264. X    after_dot,     /* Succeeds if after dot */
  265. X    begbuf,      /* Succeeds if at beginning of buffer */
  266. X    endbuf,      /* Succeeds if at end of buffer */
  267. X    wordchar,    /* Matches any word-constituent character */
  268. X    notwordchar, /* Matches any char that is not a word-constituent */
  269. X    wordbeg,     /* Succeeds if at word beginning */
  270. X    wordend,     /* Succeeds if at word end */
  271. X    wordbound,   /* Succeeds if at a word boundary */
  272. X    notwordbound, /* Succeeds if not at a word boundary */
  273. X    syntaxspec,  /* Matches any character whose syntax is specified.
  274. X            followed by a byte which contains a syntax code, Sword or such like */
  275. X    notsyntaxspec /* Matches any character whose syntax differs from the specified. */
  276. X  };
  277. X
  278. Xextern char *re_compile_pattern ();
  279. X/* Is this really advertised? */
  280. Xextern void re_compile_fastmap ();
  281. Xextern int re_search (), re_search_2 ();
  282. Xextern int re_match (), re_match_2 ();
  283. X
  284. X/* 4.2 bsd compatibility (yuck) */
  285. Xextern char *re_comp ();
  286. Xextern int re_exec ();
  287. X
  288. X#ifdef SYNTAX_TABLE
  289. Xextern char *re_syntax_table;
  290. X#endif
  291. END_OF_FILE
  292. if test 12504 -ne `wc -c <'regex.h'`; then
  293.     echo shar: \"'regex.h'\" unpacked with wrong size!
  294. fi
  295. # end of 'regex.h'
  296. fi
  297. echo shar: End of shell archive.
  298. exit 0
  299.  
  300.